package cn.clwxy.gdz.controller.presonalCenter;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.clwxy.gdz.bo.PersonalCenterInfoBean;
import cn.clwxy.gdz.service.PersonalCenterInfoActService;
import cn.clwxy.gdz.service.PersonalCenterInfoActServiceImpl;
import cn.clwxy.gdz.util.JsonSerializeHelper;

public class PersonalCenterIdentityServlet extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// System.out.println("进入。。。。。。。。。。。。。。。。。。");
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		
		String id = request.getParameter("teacherId");
		String name = request.getParameter("name_check");
		String sex = request.getParameter("sex_check");
		String school = request.getParameter("school_check");
		String major = request.getParameter("major_check");
		String retime = request.getParameter("retime_check");
		String phone = request.getParameter("phone_check");
		String comment = request.getParameter("comment_check");
		String identity = request.getParameter("identity_check");
		String job = request.getParameter("job_check");
		String reward = request.getParameter("reward_check");
		String subject = request.getParameter("subject_check");
		String address = request.getParameter("address_check");
		String src = request.getParameter("src_check");
		

		PersonalCenterInfoBean pcib = new PersonalCenterInfoBean();
		
		pcib.setSrc(src);
		pcib.setTeacherRealName(name);
		pcib.setTeacherId(Integer.parseInt(id));
		pcib.setTeacherSex(sex);
		pcib.setTeacherUniversity(school);
		pcib.setTeacherSpeciality(major);
		pcib.setTeacherPhone(phone);
		pcib.setSelfmark(comment);
		pcib.setTeacherIdentity(identity);
		pcib.setType(job);

		pcib.setCertificate(reward);
		pcib.setSubjectName(subject);
		System.out.println(comment);

		PersonalCenterInfoActService pca = new PersonalCenterInfoActServiceImpl();
		int i = pca.updateInfo(pcib);
		System.out.println(i);
		if (i > 0) {
			PersonalCenterInfoBean pe = pca.getTeacherInfo(Integer.valueOf(id));
			String json = JsonSerializeHelper.JsonSerializer(pe);
			System.out.println(json);
			response.setContentType("application/json");
			response.getWriter().write(json);
		} else {
			System.out.println("修改失败");
		}
	}

}
